package de.fh.ka.as.car.routing;

import java.util.Date;

import android.graphics.PointF;
import de.fh.ka.as.car.drivecontrol.model.Control;
import de.fh.ka.as.car.hardware.Car;

public abstract class RouteCommand {

	public static final int STATE_NULL = -2;
	public static final int STATE_START = -1;
	public static final int STATE_FINISHED = Integer.MAX_VALUE;

	protected PointF start;
	protected PointF end;
	protected int state = STATE_NULL;
	protected Date lastTime = null;
	protected Date timeStateStarted = null;
	protected int nextState = STATE_START;

	// public RouteCommand() {
	// }

	public RouteCommand(PointF start, PointF end) {
		this.start = start;
		this.end = end;
	}

	public abstract void execute(Car car, Control control);

	protected void changeToState(int newState) {
		this.nextState = newState;
	}

	public boolean isFinished(Car car) {
		return state == STATE_FINISHED;
	}

	@Override
	public String toString() {
		return String.format("RouteCommand: state=%d start=(%f , %f ) end=(%f ,%f )", state, start.x, start.x,
				end.x, end.y);
	}
}